﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;

using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.CommandBars;

namespace GnProjectAssist
{
    public abstract class GnMenuCommand : GnCommand
    {
		private CommandBarControl mBarControl;

		public GnMenuCommand( IGnPerformCommand perform, string commandName, string buttonText, string tooltipText = "" )
			: base( perform, commandName, buttonText, tooltipText )
        {
        }

		public enum eSupportCommandBar
		{
			MenuBar,
		}

        public CommandBarControl CreateMenuItem( eSupportCommandBar commandBarName, int position = 1 )
        {
			CommandBar commandBar = GnAssist.GetCommandBar( commandBarName.ToString() );
			if( commandBar == null )
				return null;

			mBarControl = commandBar.Controls.Add( MsoControlType.msoControlButton
						, Missing.Value, Missing.Value, position, true);// as CommandBarPopup;

			if( mBarControl == null )
                return null;

			mBarControl.Tag = Name;
			mBarControl.Caption = ButtonText;
			mBarControl.TooltipText = TooltipText;
			AddClickEvent( mBarControl );
			return mBarControl;	
        }

        //public void AddCommandMenu( string popupMenu, int position )
        //{
        //    CommandBarControl menuItem = CreateMenuItem( popupMenu, cmd, position );
        //    AddClickEventHandler( menuItem );
        //    AddCommandToList( cmd );
        //}
    }
}
